def button_click():
         task2 = entry1.get()
         set_time = entry2.get()
         prior = priority_stuff.get()
         try:
             set_time1 = datetime.strptime(set_time,'%Y-%m-%d %H:%M')
             task1.append((task2, prior,set_time1))
             update_task_list()
             entry1.delete(0, tk.END)
             entry2.delete(0, tk.END)
         except ValueError:
             print("无效的截止日期,请使用YYYY-MM-DD HH: MM")
             
             
def update_task_list():
         note.delete(0, tk.END)
         sorted_tasks = task_priority(task1)
         data1 = datetime.now()
         for task, priority ,set_time1 in sorted_tasks:
             color = "#8B0000" if priority == "最首要任务/High" else '#FFA500' if priority == "首要任务/Medium" else '#00008B'
             if set_time1 and data1 >=set_time1:
                 color = "#333333"
             note.insert(tk.END, f"[{priority}] {task} - {set_time1.strftime('%Y-%m-%d %H:%M')}")
             note.itemconfig(note.size() - 1, {'fg': color}) 
             
             
def cut_piece():
    cut1 = note.curselection()
    if not cut1:
        return
    for index in reversed(cut1):
        cut2= note.get(index)   
        note.delete(index)
        for i, (task, priority, set_time1) in enumerate(task1):
            task_list = f"[{priority}] {task} - {set_time1.strftime('%Y-%m-%d %H:%M')}"
            if task_list == cut2:
                task1.pop(i)
                break
    update_task_list()
    
    
task1 = []                                  